" VimFiler:" {{{
function! api#vimfiler#init()
    let g:vimfiler_safe_mode_by_default = 0
    if !exists('g:loaded_vimfiler')
        try
            packadd vimfiler
        catch /.*/
        endtry
    endif
    if exists('g:loaded_vimfiler') && g:loaded_vimfiler
        " Global options definition. "{{{
        call unite#util#set_default(
                    \ 'g:unite_kind_file_delete_file_command',
                    \ unite#util#is_windows() && !executable('rm') ? 'del $srcs' :
                    \ executable('rmtrash') ? 'rmtrash $srcs' :
                    \ executable('trash-put') ? 'trash-put $srcs' :
                    \ 'rm $srcs')
        call unite#util#set_default(
                    \ 'g:unite_kind_file_delete_directory_command',
                    \ unite#util#is_windows() && !executable('rm') ? 'rmdir $srcs' :
                    \ executable('rmtrash') ? 'rmtrash $srcs' :
                    \ executable('trash-put') ? 'trash-put $srcs' :
                    \ 'rm -r $srcs')
        call unite#util#set_default(
                    \ 'g:unite_kind_file_copy_file_command',
                    \ unite#util#is_windows() && !executable('cp') ? 'robocopy $srcs $dest' :
                    \ 'cp -p $srcs $dest')
        call unite#util#set_default(
                    \ 'g:unite_kind_file_copy_directory_command',
                    \ unite#util#is_windows() && !executable('cp') ? 'robocopy /e $srcs $dest' :
                    \ 'cp -p -r $srcs $dest')
        call unite#util#set_default(
                    \ 'g:unite_kind_file_move_command',
                    \ unite#util#is_windows() && !executable('mv') ?
                    \  'move /Y $srcs $dest' : 'mv $srcs $dest')
        call unite#util#set_default('g:unite_kind_file_use_trashbox',
                    \ unite#util#is_windows() && unite#util#has_vimproc())
        "}}}
        if empty(maparg('<Plug>(vimfiler_explorer)'))
            map <Plug>(vimfiler_explorer) <esc>:<c-u>VimFiler -explorer<cr>
        endif
        nmap <leader>v <Plug>(vimfiler_switch)
        " nmap <leader>e <Plug>(vimfiler_explorer)
        nmap <F3>      <Plug>(vimfiler_explorer)

        " file_keymap
        let g:file_keymap = get(g:, "file_keymap", { "name" : "+file" })
        let g:file_keymap.t = ["VimFilerExplorer", "toggle"]
        " vimfiler_keymap
        let g:vimfiler_keymap = get(g:, "vimfiler_keymap", { "name" : "+vimfiler" })
        let g:vimfiler_keymap.b = ["VimFilerBufferDir", "buffer"]
        let g:vimfiler_keymap.d = ["VimFilerDouble", "double"]
        let g:vimfiler_keymap.e = ["VimFilerExplorer", "explorer"]
        " space_keymap
        let g:space_keymap = get(g:, "space_keymap", { "name" : "+space" })
        let g:space_keymap.v = g:vimfiler_keymap
    endif
endfunction
" }}}
